﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NUS.ISS.ARS.BusinessEntity
{
    public abstract class BaseEntity
    {
        private string errorMessage = string.Empty;
        public Dictionary<string, string> errors = new Dictionary<string, string>();

        public bool IsValid
        {
            get { return GetIsValid(); }
        }

        public string ErrorMessage
        {
            get { return errorMessage; }
        }
        //Template Method
        public bool GetIsValid()
        {
            bool result = Valid(ref errors);
            errorMessage = EntityValidHelper.GetErrorMessageFromDictionary(errors);
            return result;
        }

        public abstract bool Valid(ref Dictionary<string, string> errors);
    }
}
